<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Document</title>
    <script src="https://cdn.bootcss.com/jquery/3.4.0/jquery.min.js"></script>
    <style>
      * {
        padding: 0;
        margin: 0;
      }
      ul li {
        list-style: none;
        width: 100px;
        height: 80px;
        float: left;
        text-align: center;
        /* color: blue; */
        position: relative;
        cursor: pointer;
      }
      ul li.active {
        color: blue;
      }
      ul li i {
        position: absolute;
        width: 100%;
        height: 3px;
        background: blue;
        left: 0;
        bottom: 0;
        display: none;
      }
      ul li i.show {
        display: block;
      }
    </style>
  </head>
  <body>
    <ul class="header">
      <li class="active">
        菜单1
        <i class="show"></i>
      </li>
      <li>
        菜单1
        <i></i>
      </li>
      <li>
        菜单1
        <i></i>
      </li>
    </ul>
    <script>
      ;(function($) {
        $.fn.menuChange = function(options) {
          var defaults = {
            //各种参数、各种属性
            classparent: "header",
            active: "active",
            tagA: "li",
            tagB: "i",
            show: "show"
          };
          //options合并到defaults上,defaults继承了options上的各种属性和方法,将所有的赋值给endOptions
          var settings = $.extend(defaults, options);
          this.each(function() {
            //实现功能的代码
            var $parent = settings.classparent;
            var $liA = settings.tagA;
            var $iB = settings.tagB;
            var $active = settings.active;
            var $show = settings.show;
            var $lis = $('.'+$parent).find($liA);
            $lis.each(function(i, item) {
              $(this).click(function() {
                $(this)
                  .addClass($active)
                  .siblings($liA)
                  .removeClass($active)
                  .end()
                  .find($iB)
                  .addClass($show)
                  .end()
                  .siblings($liA)
                  .find($iB)
                  .removeClass($show);
              });
            });
          });
        };
      })(jQuery);

      $(function() {
          $('.header').menuChange();
      });
    </script>
  </body>
</html>
